package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection()) {
            Statement statement = connection.createStatement();
            String sql = "select username,password,age from userinfo";
            ResultSet resultSet = statement.executeQuery(sql);
            while (resultSet.next()){
                String username = resultSet.getString("username");
                String password = resultSet.getString("password");
                int age = resultSet.getInt("age");
                System.out.println(username + " " + password + " " + age);
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }
}
